package com.example.yls.materialdesign_4;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by yls on 2019/4/19.
 */

public class MyFragmentPageAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> fragmentArrayList;

    public MyFragmentPageAdapter(FragmentManager fm,
                                 ArrayList<Fragment> fragmentArrayList){
        super(fm);
        this.fragmentArrayList=fragmentArrayList;
    }
    @Override
    public Fragment getItem(int position) {
        return fragmentArrayList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentArrayList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position){
            case 0:
                return "消息";
            case 1:
                return "通讯录";
            case 2:
                return "发现";
            case 3:
                return "我";
        }
        return null;
    }
}
